//
//  BQmengestView.m
//  Adorable_Things
//
//  Created by ybq on 16/1/11.
//  Copyright © 2016年 Banana Inc. All rights reserved.
//

#import "BQmengestView.h"

@implementation BQmengestView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, 15, 50, 10)];
        titleLabel.text = @"正在流行";
        titleLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:titleLabel];
        // 创建一个scrollView滑动
        _scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, titleLabel.bottom + 20, kWidth, kWidth / 3.95)];
        _scrollView.contentSize = CGSizeMake((kWidth / 3.95 + 10) * 10 + 20, 0);
        // 关闭水平条
        _scrollView.showsHorizontalScrollIndicator = NO;
        // 循环创建10button(个数是固定的,并非根据数据请求完的结果)
        for (int i = 0; i < 10; i++) {
            UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(15 + (kWidth / 3.95 + 10) * i, 0, kWidth / 3.95, kWidth / 3.95)];
            imageView.image = [UIImage imageNamed:@"placeHolder-2"];
            imageView.layer.cornerRadius = 5;
            imageView.layer.masksToBounds = YES;
            imageView.tag = 100 + i;
            UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake((imageView.frame.size.width - 40) / 2 , (imageView.frame.size.height - 20), 40, 10)];
            label.font = [UIFont systemFontOfSize:12];
            label.textAlignment = NSTextAlignmentCenter;
            label.textColor = [UIColor whiteColor];
            label.tag = 200;
            [imageView addSubview:label];
            [_scrollView addSubview:imageView];
            
        }
        [self addSubview:_scrollView];
    }
    return self;
}


@end
